<template>
  <!-- 个人简历的首页 -->
  <div class="page page-lyd">
    <div class="top-title-section">
      <h1>流程测试页面</h1>
    </div>

    <!-- 长列表 -->
    <div class="long-list-section">
      <div class="long-list-section-item" @click="clickStart">开始流程1</div>
      <div class="long-list-section-item" @click="endAction">结束流程</div>
    </div>
    <div class="long-list-section">
       <div class="long-list-section-item" @click="clickStart1">开始流程2</div>
        <div class="long-list-section-item" @click="endAction1">结束流程</div>
    </div>

    <div class="long-list-section">
       <div class="long-list-section-item" @click="clickStart2">开始流程3</div>
        <div class="long-list-section-item" @click="endAction2">结束流程</div>
    </div>

    <div class="long-list-section">
       <div class="long-list-section-item" @click="clickStart3">实例开始流程4</div>
        <div class="long-list-section-item" @click="endAction3">结束流程</div>
    </div>

    <div class="long-list-section">
      <div class="long-list-section-item">流程结果</div>
       <div class="long-list-section-item">{{ bizId }}</div>
    </div>

  </div>
</template>

<script>

  import { checkAllElig, endEligProcess } from './eligibilityController';
  import eligClass from './eligClass.js'
  export default {
    data() {
      return {
        bizId: '',
        tempParams: [
          {
            params: {
              name: '张三',
              age: 18
            },
            kindId: '0001'
          },
          {
            params: {
              name: '张三',
              age: 19
            },
            kindId: '0002'
          },
          {
            params: {
              name: '张三',
              age: 20
            },
            kindId: '0003'
          }
        ],
        eligClass: ''
      };
    },
    computed: {
       
    },
    created() {
     setInterval(() => {
      this.bizId = window.start_elig_biz_id ?? '--';
     }, 500);
    },
    mounted() {},
    beforeDestroy() {},
    methods: {
      clickStart() {
        checkAllElig(this.tempParams[0].params, this.tempParams[0].kindId, 
        (res)=>{
          console.log('success',this.tempParams[0].kindId, res);
        }, 
        (err)=>{
          console.log('failed', this.tempParams[0].kindId, err);
        });
      },

      clickStart1() {
        checkAllElig(this.tempParams[1].params, this.tempParams[1].kindId, 
        (res)=>{
          console.log('success',this.tempParams[1].kindId, res);
        }, 
        (err)=>{
          console.log('failed', this.tempParams[1].kindId, err);
        });
      },

      clickStart2() {
        checkAllElig(this.tempParams[2].params, this.tempParams[2].kindId, 
        (res)=>{
          console.log('success',this.tempParams[2].kindId, res);
        }, 
        (err)=>{
          console.log('failed', this.tempParams[2].kindId, err);
        });
      },


      endAction(){
        const tempId = this.tempParams[0].kindId;
        endEligProcess()
        console.log('endAction', tempId);
      },
      endAction1(){
        const tempId = this.tempParams[1].kindId;
        endEligProcess()
        console.log('endAction', tempId);
      },
      endAction2(){
        const tempId = this.tempParams[2].kindId;
        endEligProcess()
        console.log('endAction', tempId);
      },



      clickStart3(){
        this.creatWienNeed();
        this.eligClass.checkAllElig(this.tempParams[0].params, this.tempParams[0].kindId, 
        (res)=>{
          console.log('success',this.tempParams[0].kindId, res);
        }, 
        (err)=>{
          console.log('failed', this.tempParams[0].kindId, err);
        });
      },
      endAction3(){
        // this.eligClass.shouldStop = true;
        this.eligClass = null;
      },

      creatWienNeed(){
        if(this.eligClass){
          this.eligClass.shouldStop = true;
          console.log('end-----------------', this.eligClass.randomNumber);

          this.eligClass = null;
        }
        if(!this.eligClass){          
          this.eligClass = new eligClass();
          console.log('-----------------', this.eligClass.randomNumber);

        }       
      }



    }
  };
</script>

<style lang="less" scoped src="./style.less"></style>
